package com.gzyj.jtt808.v2011.additionalinfo;


import com.gzyj.jtt808.utils.HexBytesUtil;
import io.netty.buffer.ByteBuf;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 视频相关报警
 *
 * @author lhj
 */
@Data
@ApiModel("唐僧附加协议")
public class JTT808_0x0200_0x6A extends JTT808_AddtionalInfo implements Serializable {

    @ApiModelProperty("类型")
    public Byte Type;

    @ApiModelProperty("限速值")
    public Byte Limited;

    public JTT808_0x0200_0x6A() {
        this.setID(0x6A);
        this.setLength(2);
    }

    @Override
    public void encode(ByteBuf buf) {
        buf.writeByte(this.getID());
        buf.writeByte(2);
        buf.writeByte(this.Type);
        buf.writeByte(this.Limited);
    }

    @Override
    public JTT808_0x0200_0x6A decode(ByteBuf buf) {
        byte[] temp = HexBytesUtil.readByOffset(buf, 1);
        this.setLength(Integer.parseInt(HexBytesUtil.bytesToHex(temp), 16));
        this.Type=buf.readByte();
        this.Limited=buf.readByte();
        return this;
    }
}
